import socket
import sys

class Pipe(object):


    def startConnection(self, host,port):
        self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.s.connect((host,port))
        print 'Connected to server... type a message'
        pipe.waitForInput()

    def waitForInput(self):
        self.x = raw_input()
        self.s.send(self.x)
        data = self.s.recv(1024)
        pipe.waitForResponse()
        
    def waitForResponse(self):
        print "Echo = " , repr(self.x)
        





if __name__ == "__main__":
    ip = "127.0.0.1"
    port = 1234
    pipe = Pipe()
    pipe.startConnection(ip,port)
    ##Loop needed
    
